﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Data;
using BBS.Entity;

namespace BBS.Data.Forum
{
    public class AccountLevelTable
    {
        private static string _connstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        private BaseTable _table = new BaseTable(_connstr, "Account_Level");

        /// <summary>
        /// 返回所有用户级别信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetAll()
        {
            return _table.SelectTable();
        }

        public int Insert(AccountLevel level)
        {
            string sql = "insert into [Account_Level] (title,points) values (@title,@points)";
            return _table.ExecuteNonQuery(sql, new OleDbParameter("title", level.Title),
                                          new OleDbParameter("points", level.Points));
        }
        public int Update(AccountLevel level)
        {
            string sql = "update [Account_Level] set title=@title,points = @points where id = @id";
            return _table.ExecuteNonQuery(sql, new OleDbParameter("title", level.Title),
                                          new OleDbParameter("points", level.Points), new OleDbParameter("id", level.Id));
        }
    }
}
